<script setup>
import { provide, ref } from 'vue';
import SysHeader from './components/sys-header/index.vue';
import SysMenu from './components/sys-menu.vue';
import { useRoute } from 'vue-router';
import router from '@/router/index.js';

const route = useRoute();

const primaryMainElem = ref();
provide('primaryMainElem', primaryMainElem);
</script>

<template>
  <div class="primary">
    <template v-if="route.meta.headerVisible ?? true">
      <sys-header></sys-header>
      <sys-menu></sys-menu>

      <div class="meta">
        {{ route.meta?.title ?? 'route title' }}
        <template v-if="route.meta.back">
          <a-button class="back-btn" @click="() => router.push(route.meta.back)">返回</a-button>
        </template>
      </div>
    </template>
    <main ref="primaryMainElem">
      <router-view></router-view>
    </main>
  </div>
</template>

<style>
.primary {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: auto 1fr;
}

.primary > .sys-menu-container {
  grid-row: 2 / 4;
  width: 256px;
}

.primary > .meta {
  z-index: 1;
  display: flex;
  align-items: baseline;
  padding-left: 1.5em;
  padding-right: 1.5em;
  font-size: 16px;
  line-height: 50px;
  background: #fff;
  box-shadow: inset 0 6px 8px -4px rgba(0,0,0,.3), 0 1px 8px -4px rgba(0,0,0,.3);
}

.primary .meta .back-btn { margin-left: auto; }

.primary > main {
  grid-row-end: 4;
  grid-column-end: 3;
  background: rgb(242,243,245);
  overflow-y: auto;
}

/* .simple 上中下为 新建、表格、页 */
.primary .simple { margin: 24px; }

.primary .simple .ant-table-wrapper {
  padding: 24px;
  background: #fff;
  border-radius: 6px;
}

.primary .simple > .ant-btn:first-child { margin-bottom: 20px; }

.primary .op-btns {
  display: flex;
  gap: 1em;
}

.primary .op-btns.icon .ant-btn {
  padding-left: 0;
  padding-right: 0;
}

/* --- */

.task-assign {
  width: 900px;
  padding: 24px;
  margin: 24px auto;
  background: #fff;
}

.task-assign .ant-spin-container { min-height: 300px; }

.task-assign .ant-upload.ant-upload-drag {
  margin-bottom: 10px;
  height: 113px;
}

.task-assign .sub-bar {
  display: flex;
  align-items: baseline;
  gap: 2em;
  border-bottom: 1px solid rgb(228,228,228);
}

.task-assign .table-container {
  position: relative;
  padding-top: 1em;
}

.task-assign .table-container > .for-all-tip {
  position: absolute;
  top: -1.5em;
  color: rgb(200,0,0);
}

.task-assign .table-container > .ant-table-wrapper { margin-top: 1.5em; }

.task-assign header:first-of-type {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1em;
}

.task-assign-modal .ant-upload-list {
  overflow-y: auto;
  max-height: 300px;
}
</style>
